import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { LocalStorageService } from 'src/app/services/local-storage/local-storage.service';

@Component({
  selector: 'app-index',
  templateUrl: './index.component.html',
  styleUrls: ['./index.component.css']
})
export class IndexComponent implements OnInit {
  constructor(
    public router: Router,
    private localStorage: LocalStorageService
  ) {
    const token = this.localStorage.get('token');
    if (!token) {
      this.router.navigateByUrl('/login');
    }
  }

  ngOnInit() {}
}
